package com.zrx.controller;

import com.zrx.domain.ResponseResult;
import com.zrx.enums.AppHttpCodeEnum;
import com.zrx.exception.SystemException;
import com.zrx.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 张荣欣
 * @create ：2022/10/8  15:16
 */
@RestController
@Api(tags = "图片上传")
public class UploadController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("/upload")
    @ApiOperation(value = "图片上传",notes = "图片上传")
    public ResponseResult uploadImg(@RequestParam MultipartFile img){
        try {
            return uploadService.uploadImg(img);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("文件上传失败");
        }
    }
}
